package com.shadow.ui.container.top.base
{
	import com.shadow.ui.container.town.base.TownContainer;
	import com.shadow.ui.custom.CustomSprite;
	import com.shadow.ui.map.stage.base.MapStage;
	
	import flash.events.Event;
	import flash.events.EventPhase;
	import flash.events.MouseEvent;
	import flash.ui.Mouse;
	import flash.ui.MouseCursor;
	
	public class TopContainer extends CustomSprite
	{
		public var mapStage:MapStage;
		public var townContainer:TownContainer;
		
		public function TopContainer()
		{
			this.tabChildren = false;
			this.tabEnabled = false;
			
			this.addEvent();
		}
		
		private function addEvent():void
		{
			addEventListener(Event.ADDED_TO_STAGE, this.addedHandler);
		}
		
		private function addedHandler(event:Event):void
		{
			this.removeEventListener(Event.ADDED_TO_STAGE,addedHandler);
			if ((event.eventPhase == EventPhase.AT_TARGET) && (this == event.currentTarget))
			{
				if (false == hasEventListener(MouseEvent.ROLL_OVER))
				{
					addEventListener(MouseEvent.ROLL_OVER, this.mouseRollOverHandler);
				}
			}
		}
		
		private function mouseRollOverHandler(event:MouseEvent):void
		{
			if(mapStage!=null){
				mapStage.clearMouseMoveOperation();
			}
			
			if (MouseCursor.AUTO != Mouse.cursor)
			{
				Mouse.cursor = MouseCursor.AUTO;
			}
		}
	}
}